<script lang="tsx">
import { defineComponent, getCurrentInstance, h } from 'vue'
export default defineComponent({
  name: 'OptionContent',
  props: ['option'],
  setup(props) {
    const instance = getCurrentInstance()

    return () => {
      const getParent: any = (vm: any) => {
        if (vm.type.name === 'V8TransferPanel') {
          return vm
        } else if (vm.parent) {
          return getParent(vm.parent)
        } else {
          return vm
        }
      }
      const panel = getParent(instance)
      const transfer = panel.parent || panel
      return panel.proxy.renderContent ? (
        panel.proxy.renderContent(h, props.option)
      ) : transfer.slots?.default ? (
        transfer.slots?.default({ option: props.option })
      ) : (
        <span>{props.option[panel.proxy.labelProp] || props.option[panel.proxy.keyProp]}</span>
      )
    }
  }
})
</script>
